package com.yy.common.utils;

import static com.baomidou.mybatisplus.core.toolkit.StringPool.ZERO;

/**
 * ClassName: TimeUtils
 * Package: com.yy.common.utils
 * Description:
 *
 * @Author yy
 * @Create 2023-12-13 14:08
 * @Version 1.0
 */
public class TimeUtils {
    /**
     * 获取时间毫秒
     *
     * @param time 格式:"00:00:10.68"
     * @return
     */
    public static long getTime(String time) {
        int min = 0;
        String[] strs = time.split(":");
        if (strs[0].compareTo(ZERO) > 0) {
            // 秒
            min += Long.parseLong(strs[0]) * 60 * 60 * 1000;
        }
        if (strs[1].compareTo(ZERO) > 0) {
            min += Long.parseLong(strs[1]) * 60 * 1000;
        }
        if (strs[2].compareTo(ZERO) > 0) {
            min += Math.round(Double.parseDouble(strs[2]) * 1000);
        }
        return min;
    }
}
